<%@ page contentType="text/html;charset=UTF-8" language="java" %>


<html>

<head>
    <%@include file="../common/include.jsp" %>
    <title>流程管理系统 - 首页</title>
    <link rel="icon" href="<%=path%>/favicon.ico" mce_href="<%=path%>/favicon.ico" type="image/x-icon">
    <link rel="shortcut icon" href="<%=path%>/favicon.ico" mce_href="<%=path%>/favicon.ico" type="image/x-icon">
    <style>
        .my {
            background-color: #1ab394 !important;
            color: white !important;
        }

        .avatar {
            display: inline-block;
            width: 70px;
            height: 70px;
            text-align: center;
            line-height: 70px;
            border: 2px solid #fff;
            border-radius: 50%;
            color: #fff;
            font-size: 40px
        }
    </style>

    <script>
        $(document).ready(function () {
            //页面跳转  左边菜单链接点击后通过本函数跳转，防止直接看到url地址信息
            $(".J_menuItem").click(function () {
                $(".J_menuItem").removeClass("my");
                $(this).addClass("my");

                $('#myiframe').attr('src', $(this).attr('uri'));
                $('#myiframe').attr('src', $('#myiframe').attr('src'));

            });
        });

        var flag = true;

        function hideMenu() {
            if (flag) {
                $("body").addClass(" mini-navbar");
                flag = false;
                $('#foldbtn i').removeClass('fa-arrow-left').addClass('fa-arrow-right').parent().attr('title', '展开左侧栏')
            }
            else {
                $("body").removeClass(" mini-navbar");
                flag = true;
                $('#foldbtn i').removeClass('fa-arrow-right').addClass('fa-arrow-left').parent().attr('title', '收起左侧栏')

            }
        }

        $.ajax({
            url: 'getMessage.html',
            type: 'post',
            dataType: 'json',
            success: function (data) {
                    setHtml(data.list,data.size);
            }
        });

        //页面消息轮询
        setInterval(function () {
            getMsgNum();
        }, 1000 * 60*5);

        function getMsgNum() {
            $.ajax({
                url: 'getMessage.html',
                type: 'post',
                dataType: 'json',
                success: function (data) {
                    setHtml(data.list,data.size);
                }
            });
        }

        function setHtml(list,size){
            if (null != list && size > 0) {
                $("#messageSize").html(size);
                var str = "";
                var ids = "";
                for (var i =0; i < size; i++){
                    var demand_type = list[i].demand_type;
                    if ("1" == demand_type){
                        str += "BUG";
                    }
                    if ("2" == demand_type){
                        str += "需求";
                    }
                    ids += list[i].id +",";
                    str += "编号"+list[i].dem_id+"变更状态为："+list[i].status_text+"";
                    str += "<span  style='margin-left: 35px; id='span"+list[i].dem_id+"'><a onclick='changeLooked("+list[i].id+",this)'>确认</a></span><legend></legend>";
                }

                $("#messageIds").val(ids);
                $("#messageDiv").html(str);
            }
        }


        function changeLooked(id,obj) {

                $.ajax({
                    url: 'updMess.html',
                    type: 'post',
                    dataType: 'json',
                    data:{"ids":id},
                    success: function (data) {
                        $(obj).parent().html("<span>已确认</span>");
                    }
                });
        }

        function clearMessageSize(){
            $("#messageSize").html("");
        }
    </script>
</head>

<body class="fixed-sidebar full-height-layout gray-bg" style="overflow:hidden">
<div id="wrapper">
    <!--左侧导航开始-->
    <nav class="navbar-default navbar-static-side" role="navigation">
        <div class="nav-close"><i class="fa fa-times-circle"></i>
        </div>
        <div class="sidebar-collapse">
            <ul class="nav" id="side-menu">
                <li class="nav-header">
                    <div class="dropdown profile-element">
                        <span class="avatar">${user.realname.substring(0,1)}</span>
                        <a data-toggle="dropdown" class="dropdown-toggle" href="#">
                                    <span class="clear">
                               <span style="margin-top:15px;margin-bottom:5px" class="block m-t-xs"><strong
                                       class="font-bold">${user.realname }</strong></span>
                                    <span class="text-muted text-xs block">${role.name}</span>
                                    </span>
                        </a>
                        <%--<ul class="dropdown-menu animated fadeInRight m-t-xs">--%>
                        <%--<li><a class="J_menuItem" href="form_avatar.html">修改头像</a>--%>
                        <%--</li>--%>
                        <%--<li><a class="J_menuItem" href="profile.html">个人资料</a>--%>
                        <%--</li>--%>
                        <%--<li><a class="J_menuItem" href="contacts.html">联系我们</a>--%>
                        <%--</li>--%>
                        <%--<li><a class="J_menuItem" href="mailbox.html">信箱</a>--%>
                        <%--</li>--%>
                        <%--<li class="divider"></li>--%>
                        <%--<li><a href="loginout.html">安全退出</a>--%>
                        <%--</li>--%>
                        <%--</ul>--%>
                    </div>
                    <div class="logo-element">
                        <img src="h/img/logo_mini.png" alt="">
                    </div>
                </li>

                <c:forEach var="superMenu" items="${rightsList}">
                    <li <c:if test="${superMenu.name == '流程管理'}">class='active'</c:if>>
                        <a href="#">
                            <i class="fa ${superMenu.icoPath}"></i>
                            <span class="nav-label"> ${superMenu.name }</span>
                            <span class="fa arrow"></span>
                        </a>
                        <ul class="nav nav-second-level<c:if test="${superMenu.name == '流程管理'}"> collapse in</c:if>">

                            <c:forEach var="secMenu" items="${superMenu.secondMenu }">
                                <li>
                                    <a class="J_menuItem<c:if test="${secMenu.name == '问题列表'}"> my</c:if>"
                                       uri="${secMenu.url }">${secMenu.name }</a>
                                </li>
                            </c:forEach>
                        </ul>

                    </li>
                </c:forEach>
            </ul>
        </div>
    </nav>
    <!--左侧导航结束-->
    <!--右侧部分开始-->
    <div id="page-wrapper" class="gray-bg dashbard-1">
        <div class="row content-tabs">
            <a class="btn btn-primary " style="margin-left: 5px;margin-top: 5px" href="#" onclick="hideMenu()"
               id="foldbtn" title="收起左侧栏"><i class="fa fa-arrow-left"></i> </a>


            <a href="loginout.html" class="roll-nav roll-right J_tabExit"><i class="fa fa fa-sign-out"></i> 退出</a>
        </div>
        <div class="row J_mainContent" id="content-main">
            <iframe class="J_iframe" src="getAlldemand.html?myDemand=true" name="myiframe" id="myiframe" width="100%"
                    height="100%" frameborder="0"></iframe>
        </div>
        <div class="footer">
            <div class="pull-right">&copy; 2017&nbsp;<a href="http://www.zhdclink.com/" target="_blank">中环互联</a>
            </div>
        </div>
    </div>
    <!--右侧部分结束-->

    <!--mini聊天窗口开始-->
    <div  class="small-chat-box fadeInRight animated" style="height: 200px;width: 300px">

        <div class="heading" draggable="true">
            消息提醒
        </div>

        <div id="messageDiv" class="content">

        </div>

    </div>

    <div id="small-chat">
        <span  id="messageSize" class="badge badge-warning pull-right"></span>
        <a class="open-small-chat" onclick="clearMessageSize()">
            <i class="fa fa-comments"></i>

        </a>
    </div>

    <input type="hidden" id="messageIds" value="">
</div>


</body>

</html>